package replaceSpace;

public class Main {
    public String replaceSpace(String str){
        str=str.replaceAll(" ","%20");
        return  str;
    }
    public String ReplaceSpace(String s){
       StringBuffer stringBuffer=new StringBuffer();
       for (char x : s.toCharArray()){//相当于开了一个字符串缓冲区 将读入进来的StringtoCharArrary 然后用for遍历 遇到“ ”替换“%20” 填充 否则填充原数组 然后在操作结束后return  stringbuffer.toString
           if(x==' '){
               stringBuffer.append("%20");
           }
           else stringBuffer.append(x);
       }
       return stringBuffer.toString();
    }
    public static void main(String[] args){

    }
}
